package com.netinfo.learning.consumer.service.impl;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netinfo.learning.consumer.service.ConsumerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class ConsumerServiceImpl implements ConsumerService {
    @Autowired
    private RestTemplate restTemplate;

    @Override
    @HystrixCommand(fallbackMethod = "errorMethod")
    public String testMethod() {
        restTemplate.getForObject("http://common-service/hello",String.class);
        return "服务调用成功。。。。";
    }

    public String errorMethod(){
        return "error.....";
    }
}
